.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GDALWARP" "1" "Feb 08, 2024" "" "GDAL"
.SH NAME
gdalwarp \- Image reprojection and warping utility.
.SH SYNOPSIS
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp [\-\-help] [\-\-help\-general] [\-\-formats]
    [\-b|\-srcband <n>]... [\-dstband <n>]...
    [\-s_srs <srs_def>] [\-t_srs <srs_def>] [\-ct <string>]
    [\-to <NAME>=<VALUE>]... [\-vshift | \-novshift]
    [\-s_coord_epoch <epoch>] [\-t_coord_epoch <epoch>]
    [\-order n | \-tps | \-rpc | \-geoloc] [\-et <err_threshold>]
    [\-refine_gcps <tolerance> [<minimum_gcps>]]
    [\-te <xmin> <ymin> <xmax> <ymax>] [\-te_srs <srs_def>]
    [\-tr <xres> <yres>]|[\-tr square] [\-tap] [\-ts <width> <height>]
    [\-ovr <level>|AUTO|AUTO\-<n>|NONE] [\-wo <NAME>=<VALUE>]... [\-ot Byte/Int16/...] [\-wt Byte/Int16]
    [\-srcnodata \(dq<value>[ <value>...]\(dq][\-dstnodata \(dq<value>[ <value>...]\(dq]
    [\-srcalpha|\-nosrcalpha] [\-dstalpha]
    [\-r <resampling_method>] [\-wm <memory_in_mb>] [\-multi] [\-q]
    [\-cutline <datasource>] [\-cl <layer>] [\-cwhere <expression>]
    [\-csql <statement>] [\-cblend <dist_in_pixels>] [\-crop_to_cutline]
    [\-if <format>]... [\-of <format>] [\-co <NAME>=<VALUE>]... [\-overwrite]
    [\-nomd] [\-cvmd <meta_conflict_value>] [\-setci] [\-oo <NAME>=<VALUE>]...
    [\-doo <NAME>=<VALUE>]...
    <srcfile>... <dstfile>
.ft P
.fi
.UNINDENT
.UNINDENT
.SH DESCRIPTION
.sp
The \fBgdalwarp\fP utility is an image mosaicing, reprojection and warping
utility. The program can reproject to any supported projection,
and can also apply GCPs stored with the image if the image is \(dqraw\(dq
with control information.
.INDENT 0.0
.TP
.B \-\-help
Show this help message and exit
.UNINDENT
.INDENT 0.0
.TP
.B \-\-help\-general
Gives a brief usage message for the generic GDAL commandline options and exit.
.UNINDENT
.INDENT 0.0
.TP
.B \-b <n>
.UNINDENT
.INDENT 0.0
.TP
.B \-srcband <n>
New in version 3.7.

.sp
Specify an input band number to warp (between 1 and the number of bands
of the source dataset).
.sp
This option is used to warp a subset of the input bands. All input bands
are used when it is not specified.
.sp
This option may be repeated multiple times to select several input bands.
The order in which bands are specified will be the order in which they
appear in the output dataset (unless \fI\%\-dstband\fP is specified).
.sp
The alpha band should not be specified in the list, as it will be
automatically retrieved (unless \fI\%\-nosrcalpha\fP is specified).
.sp
The following invocation will warp an input datasets with bands ordered as
Blue, Green, Red, NearInfraRed in an output dataset with bands ordered as
Red, Green, Blue.
.INDENT 7.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp in_bgrn.tif out_rgb.tif \-b 3 \-b 2 \-b 1 \-overwrite
.ft P
.fi
.UNINDENT
.UNINDENT
.UNINDENT
.INDENT 0.0
.TP
.B \-dstband <n>
New in version 3.7.

.sp
Specify the output band number in which to warp. In practice, this option
is only useful when updating an existing dataset, e.g to warp one band at
at time.
.INDENT 7.0
.INDENT 3.5
.sp
.nf
.ft C
gdal_create \-if in_red.tif \-bands 3 out_rgb.tif
gdalwarp in_red.tif out_rgb.tif \-srcband 1 \-dstband 1
gdalwarp in_green.tif out_rgb.tif \-srcband 1 \-dstband 2
gdalwarp in_blue.tif out_rgb.tif \-srcband 1 \-dstband 3
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
If \fI\%\-srcband\fP is specified, there must be as many occurrences of
\fI\%\-dstband\fP as there are of \fI\%\-srcband\fP\&.
.sp
The output alpha band should not be specified, as it will be automatically
created if the input dataset has an alpha band, or if \fI\%\-dstalpha\fP
is specified.
.sp
If \fI\%\-dstband\fP is not specified, then
\fB\-dstband 1 \-dstband 2 ... \-dstband N\fP is assumed where N is the number
of input bands (specified explicitly either with \fI\%\-srcband\fP or
implicitly)
.UNINDENT
.INDENT 0.0
.TP
.B \-s_srs <srs def>
Set source spatial reference. If not specified the SRS found in the input
dataset will be used.
.sp
The coordinate reference systems that can be passed are anything supported by the
OGRSpatialReference.SetFromUserInput() call, which includes EPSG Projected,
Geographic or Compound CRS (i.e. EPSG:4296), a well known text (WKT) CRS definition,
PROJ.4 declarations, or the name of a .prj file containing a WKT CRS definition.
.sp
Starting with GDAL 2.2, if the SRS has an explicit
vertical datum that points to a PROJ.4 geoidgrids, and the input dataset is a
single band dataset, a vertical correction will be applied to the values of the
dataset.
.UNINDENT
.INDENT 0.0
.TP
.B \-s_coord_epoch <epoch>
New in version 3.4.

.sp
Assign a coordinate epoch, linked with the source SRS. Useful when the
source SRS is a dynamic CRS. Only taken into account if \fI\%\-s_srs\fP
is used.
.sp
Before PROJ 9.4, \fI\%\-s_coord_epoch\fP and \fI\%\-t_coord_epoch\fP are
mutually exclusive, due to lack of support for transformations between two dynamic CRS.
.UNINDENT
.INDENT 0.0
.TP
.B \-t_srs <srs_def>
Set target spatial reference.
.sp
A source SRS must be available for reprojection to occur. The source SRS
will be by default the one found in the input dataset when it is available,
or as overridden by the user with \fI\%\-s_srs\fP
.sp
The coordinate reference systems that can be passed are anything supported by the
OGRSpatialReference.SetFromUserInput() call, which includes EPSG Projected,
Geographic or Compound CRS (i.e. EPSG:4296), a well known text (WKT) CRS definition,
PROJ.4 declarations, or the name of a .prj file containing a WKT CRS definition.
.sp
Starting with GDAL 2.2, if the SRS has an explicit
vertical datum that points to a PROJ.4 geoidgrids, and the input dataset is a
single band dataset, a vertical correction will be applied to the values of the
dataset.
.UNINDENT
.INDENT 0.0
.TP
.B \-t_coord_epoch <epoch>
New in version 3.4.

.sp
Assign a coordinate epoch, linked with the target SRS. Useful when the
target SRS is a dynamic CRS. Only taken into account if \fI\%\-t_srs\fP
is used.
.sp
Before PROJ 9.4, \fI\%\-s_coord_epoch\fP and \fI\%\-t_coord_epoch\fP are
mutually exclusive, due to lack of support for transformations between two dynamic CRS.
.UNINDENT
.INDENT 0.0
.TP
.B \-ct <string>
A PROJ string (single step operation or multiple step string
starting with +proj=pipeline), a WKT2 string describing a CoordinateOperation,
or a \fI\%urn:ogc:def:coordinateOperation:EPSG::XXXX\fP URN overriding the default
transformation from the source to the target CRS. It must take into account the
axis order of the source and target CRS.
When creating a new output file, using \fI\%\-t_srs\fP is still necessary
to have the target CRS written in the metadata of the output file,
but the parameters of the CoordinateOperation will override those of the
standard transformation.
.sp
New in version 3.0.

.UNINDENT
.INDENT 0.0
.TP
.B \-to <NAME>=<VALUE>
Set a transformer option suitable to pass to \fI\%GDALCreateGenImgProjTransformer2()\fP\&.
See \fI\%GDALCreateRPCTransformerV2()\fP for RPC specific options.
.UNINDENT
.INDENT 0.0
.TP
.B \-vshift
Force the use of vertical shift. This option is generally not necessary,
except when using an explicit coordinate transformation (\fI\%\-ct\fP),
and not specifying an explicit source and target SRS.
.sp
New in version 3.4.

.UNINDENT
.INDENT 0.0
.TP
.B \-novshift
Disable the use of vertical shift when one of the source or target SRS has
an explicit vertical datum, and the input dataset is a single band dataset.
.sp
\fBNOTE:\fP
.INDENT 7.0
.INDENT 3.5
this option was named \fB\-novshiftgrid\fP in GDAL 2.2 to 3.3.
.UNINDENT
.UNINDENT
.sp
New in version 3.4.

.UNINDENT
.INDENT 0.0
.TP
.B \-order <n>
order of polynomial used for warping (1 to 3). The default is to select
a polynomial order based on the number of GCPs.
.UNINDENT
.INDENT 0.0
.TP
.B \-tps
Force use of thin plate spline transformer based on available GCPs.
.UNINDENT
.INDENT 0.0
.TP
.B \-rpc
Force use of RPCs.
.UNINDENT
.INDENT 0.0
.TP
.B \-geoloc
Force use of Geolocation Arrays.
.UNINDENT
.INDENT 0.0
.TP
.B \-et <err_threshold>
Error threshold for transformation approximation (in pixel units \-
defaults to 0.125, unless, starting with GDAL 2.1, the RPC_DEM transformer
option is specified, in which case, an exact transformer, i.e.
err_threshold=0, will be used).
.UNINDENT
.INDENT 0.0
.TP
.B \-refine_gcps <tolerance> [<minimum_gcps>]
Refines the GCPs by automatically eliminating outliers.
Outliers will be eliminated until minimum_gcps are left or when no outliers can be detected.
The tolerance is passed to adjust when a GCP will be eliminated.
Not that GCP refinement only works with polynomial interpolation.
The tolerance is in pixel units if no projection is available, otherwise it is in SRS units.
If minimum_gcps is not provided, the minimum GCPs according to the polynomial model is used.
.UNINDENT
.INDENT 0.0
.TP
.B \-te <xmin> <ymin> <xmax> <ymax>
Set georeferenced extents of output file to be created (in target SRS by
default, or in the SRS specified with \fI\%\-te_srs\fP)
.UNINDENT
.INDENT 0.0
.TP
.B \-te_srs <srs_def>
Specifies the SRS in
which to interpret the coordinates given with \-te. The <srs_def> may
be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file
containing the WKT.
This must not be confused with \-t_srs which is the target SRS of the output
dataset. \fI\%\-te_srs\fP is a convenience e.g. when knowing the output coordinates in a
geodetic long/lat SRS, but still wanting a result in a projected coordinate system.
.UNINDENT
.INDENT 0.0
.TP
.B \-tr <xres> <yres> | \-tr square
Set output file resolution (in target georeferenced units).
.sp
If not specified (or not deduced from \-te and \-ts), gdalwarp will, in the
general case, generate an output raster with xres=yres.
.sp
Starting with GDAL 3.7, if neither \fI\%\-tr\fP nor \fI\%\-ts\fP are specified,
that no reprojection is involved (including taking into account geolocation arrays
or RPC), the resolution of the source file(s) will be preserved (in previous
version, an output raster with xres=yres was always generated).
It is possible to ask square pixels to still be generated, by specifying
\fBsquare\fP as the value for \fI\%\-tr\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.B \-tap
(target aligned pixels) align the coordinates of the extent of the output
file to the values of the \fI\%\-tr\fP, such that the aligned extent
includes the minimum extent (edges lines/columns that are detected as
blank, before actual warping, will be removed starting with GDAL 3.8).
Alignment means that xmin / resx, ymin / resy,
xmax / resx and ymax / resy are integer values.
.UNINDENT
.INDENT 0.0
.TP
.B \-ts <width> <height>
Set output file size in pixels and lines. If width or height is set to 0,
the other dimension will be guessed from the computed resolution. Note that
\fI\%\-ts\fP cannot be used with \fI\%\-tr\fP
.UNINDENT
.INDENT 0.0
.TP
.B \-ovr <level>|AUTO|AUTO\-<n>|NONE
To specify which overview level of source files must be used. The default choice,
AUTO, will select the overview level whose resolution is the closest to the
target resolution. Specify an integer value (0\-based, i.e. 0=1st overview level)
to select a particular level. Specify AUTO\-n where n is an integer greater or
equal to 1, to select an overview level below the AUTO one. Or specify NONE to
force the base resolution to be used (can be useful if overviews have been
generated with a low quality resampling method, and the warping is done using a
higher quality resampling method).
.UNINDENT
.INDENT 0.0
.TP
.B \-wo <NAME>=<VALUE>
Set a warp option.  The \fI\%GDALWarpOptions::papszWarpOptions\fP docs show all options.
Multiple \fI\%\-wo\fP options may be listed.
.UNINDENT
.INDENT 0.0
.TP
.B \-ot <type>
Force the output image bands to have a specific data type supported by the
driver, which may be one of the following: \fBByte\fP, \fBInt8\fP, \fBUInt16\fP,
\fBInt16\fP, \fBUInt32\fP, \fBInt32\fP, \fBUInt64\fP, \fBInt64\fP, \fBFloat32\fP, \fBFloat64\fP, \fBCInt16\fP,
\fBCInt32\fP, \fBCFloat32\fP or \fBCFloat64\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.B \-wt <type>
Working pixel data type. The data type of pixels in the source image and
destination image buffers.
.UNINDENT
.INDENT 0.0
.TP
.B \-r <resampling_method>
Resampling method to use. Available methods are:
.sp
\fBnear\fP: nearest neighbour resampling (default, fastest algorithm, worst interpolation quality).
.sp
\fBbilinear\fP: bilinear resampling.
.sp
\fBcubic\fP: cubic resampling.
.sp
\fBcubicspline\fP: cubic spline resampling.
.sp
\fBlanczos\fP: Lanczos windowed sinc resampling.
.sp
\fBaverage\fP: average resampling, computes the weighted average of all non\-NODATA contributing pixels.
.sp
\fBrms\fP root mean square / quadratic mean of all non\-NODATA contributing pixels (GDAL >= 3.3)
.sp
\fBmode\fP: mode resampling, selects the value which appears most often of all the sampled points. In the case of ties, the first value identified as the mode will be selected.
.sp
\fBmax\fP: maximum resampling, selects the maximum value from all non\-NODATA contributing pixels.
.sp
\fBmin\fP: minimum resampling, selects the minimum value from all non\-NODATA contributing pixels.
.sp
\fBmed\fP: median resampling, selects the median value of all non\-NODATA contributing pixels.
.sp
\fBq1\fP: first quartile resampling, selects the first quartile value of all non\-NODATA contributing pixels.
.sp
\fBq3\fP: third quartile resampling, selects the third quartile value of all non\-NODATA contributing pixels.
.sp
\fBsum\fP: compute the weighted sum of all non\-NODATA contributing pixels (since GDAL 3.1)
.sp
\fBNOTE:\fP
.INDENT 7.0
.INDENT 3.5
When downsampling is performed (use of \fI\%\-tr\fP or \fI\%\-ts\fP), existing
overviews (either internal/implicit or external ones) on the source image
will be used by default by selecting the closest overview to the desired output
resolution.
The resampling method used to create those overviews is generally not the one you
specify through the \fI\%\-r\fP option. Some formats, like JPEG2000, can contain
significant outliers due to wavelet compression works. It might thus be useful in
those situations to use the \fI\%\-ovr\fP \fBNONE\fP option to prevent existing overviews to
be used.
.UNINDENT
.UNINDENT
.UNINDENT
.INDENT 0.0
.TP
.B \-srcnodata \(dq<value>[ <value>]...\(dq
Set nodata masking values for input bands (different values can be supplied
for each band). If more than one value is supplied all values should be quoted
to keep them together as a single operating system argument.
Masked values will not be used in interpolation (details given in \fI\%Nodata / source validity mask handling\fP)
.sp
Use a value of \fBNone\fP to ignore intrinsic nodata settings on the source dataset.
.sp
When this option is set to a non\-\fBNone\fP value, it causes the \fBUNIFIED_SRC_NODATA\fP
warping option (see \fI\%GDALWarpOptions::papszWarpOptions\fP) to be
set to \fBYES\fP, if it is not explicitly set.
.sp
If \fB\-srcnodata\fP is not explicitly set, but the source dataset has nodata values,
they will be taken into account, with \fBUNIFIED_SRC_NODATA\fP at \fBPARTIAL\fP
by default.
.UNINDENT
.INDENT 0.0
.TP
.B \-dstnodata \(dq<value>[ <value>]...\(dq
Set nodata values
for output bands (different values can be supplied for each band).  If more
than one value is supplied all values should be quoted to keep them together
as a single operating system argument.  New files will be initialized to this
value and if possible the nodata value will be recorded in the output
file. Use a value of \fBNone\fP to ensure that nodata is not defined.
If this argument is not used then nodata values will be copied from the source dataset.
.UNINDENT
.INDENT 0.0
.TP
.B \-srcalpha
Force the last band of a source image to be
considered as a source alpha band.
.UNINDENT
.INDENT 0.0
.TP
.B \-nosrcalpha
Prevent the alpha band of a source image to be
considered as such (it will be warped as a regular band)
.sp
New in version 2.2.

.UNINDENT
.INDENT 0.0
.TP
.B \-dstalpha
Create an output alpha band to identify nodata (unset/transparent) pixels.
.UNINDENT
.INDENT 0.0
.TP
.B \-wm <memory_in_mb>
Set the amount of memory that the
warp API is allowed to use for caching. The value is interpreted as being
in megabytes if the value is less than 10000. For values >=10000, this is
interpreted as bytes.
.sp
The warper will total up the memory required to hold the input and output
image arrays and any auxiliary masking arrays and if they are larger than
the \(dqwarp memory\(dq allowed it will subdivide the chunk into smaller chunks
and try again.
.sp
If the \-wm value is very small there is some extra overhead in doing many
small chunks so setting it larger is better but it is a matter of
diminishing returns.
.UNINDENT
.INDENT 0.0
.TP
.B \-multi
Use multithreaded warping implementation.
Two threads will be used to process chunks of image and perform
input/output operation simultaneously. Note that computation is not
multithreaded itself. To do that, you can use the \fI\%\-wo\fP NUM_THREADS=val/ALL_CPUS
option, which can be combined with \fI\%\-multi\fP
.UNINDENT
.INDENT 0.0
.TP
.B \-q
Be quiet.
.UNINDENT
.INDENT 0.0
.TP
.B \-if <format>
Format/driver name to be attempted to open the input file(s). It is generally
not necessary to specify it, but it can be used to skip automatic driver
detection, when it fails to select the appropriate driver.
This option can be repeated several times to specify several candidate drivers.
Note that it does not force those drivers to open the dataset. In particular,
some drivers have requirements on file extensions.
.sp
New in version 3.2.

.UNINDENT
.INDENT 0.0
.TP
.B \-of <format>
Select the output format. Starting with GDAL 2.3, if not specified, the
format is guessed from the extension (previously was GTiff). Use the short
format name.
.UNINDENT
.INDENT 0.0
.TP
.B \-co <NAME>=<VALUE>
Many formats have one or more optional creation options that can be
used to control particulars about the file created. For instance,
the GeoTIFF driver supports creation options to control compression,
and whether the file should be tiled.
.sp
The creation options available vary by format driver, and some
simple formats have no creation options at all. A list of options
supported for a format can be listed with the
\fI\%\-\-formats\fP
command line option but the documentation for the format is the
definitive source of information on driver creation options.
See \fI\%Raster drivers\fP format
specific documentation for legal creation options for each format.
.UNINDENT
.INDENT 0.0
.TP
.B \-cutline <datasource>
Enable use of a blend cutline from the name OGR support datasource.
.UNINDENT
.INDENT 0.0
.TP
.B \-cl <layername>
Select the named layer from the cutline datasource.
.UNINDENT
.INDENT 0.0
.TP
.B \-cwhere <expression>
Restrict desired cutline features based on attribute query.
.UNINDENT
.INDENT 0.0
.TP
.B \-csql <query>
Select cutline features using an SQL query instead of from a layer with \fI\%\-cl\fP\&.
.UNINDENT
.INDENT 0.0
.TP
.B \-cblend <distance>
Set a blend distance to use to blend over cutlines (in pixels).
.UNINDENT
.INDENT 0.0
.TP
.B \-crop_to_cutline
Crop the extent of the target dataset to the extent of the cutline.
.UNINDENT
.INDENT 0.0
.TP
.B \-overwrite
Overwrite the target dataset if it already exists. Overwriting must be understood
here as deleting and recreating the file from scratch. Note that if this option
is \fInot\fP specified and the output file already exists, it will be updated in
place.
.UNINDENT
.INDENT 0.0
.TP
.B \-nomd
Do not copy metadata. Without this option, dataset and band metadata
(as well as some band information) will be copied from the first source dataset.
Items that differ between source datasets will be set to * (see \fI\%\-cvmd\fP option).
.UNINDENT
.INDENT 0.0
.TP
.B \-cvmd <meta_conflict_value>
Value to set metadata items that conflict between source datasets
(default is \(dq*\(dq). Use \(dq\(dq to remove conflicting items.
.UNINDENT
.INDENT 0.0
.TP
.B \-setci
Set the color interpretation of the bands of the target dataset from
the source dataset.
.UNINDENT
.INDENT 0.0
.TP
.B \-oo <NAME>=<VALUE>
Dataset open option (format specific)
.UNINDENT
.INDENT 0.0
.TP
.B \-doo <NAME>=<VALUE>
Output dataset open option (format specific)
.sp
New in version 2.1.

.UNINDENT
.INDENT 0.0
.TP
.B <srcfile>
The source file name(s).
.UNINDENT
.INDENT 0.0
.TP
.B <dstfile>
The destination file name.
.UNINDENT
.sp
Mosaicing into an existing output file is supported if the output file
already exists. The spatial extent of the existing file will not
be modified to accommodate new data, so you may have to remove it in that case, or
use the \-overwrite option.
.sp
Polygon cutlines may be used as a mask to restrict the area of the
destination file that may be updated, including blending.  If the OGR
layer containing the cutline features has no explicit SRS, the cutline
features must be in the SRS of the destination file. When writing to a
not yet existing target dataset, its extent will be the one of the
original raster unless \-te or \-crop_to_cutline are specified.
.sp
Starting with GDAL 3.1, it is possible to use as output format a driver that
only supports the CreateCopy operation. This may internally imply creation of
a temporary file.
.SH NODATA / SOURCE VALIDITY MASK HANDLING
.sp
Invalid values in source pixels, either identified through a nodata value
metadata set on the source band, a mask band, an alpha band or the use of
\fI\%\-srcnodata\fP will not be used in interpolation.
The details of how it is taken into account depends on the resampling kernel:
.INDENT 0.0
.IP \(bu 2
for nearest resampling, for each target pixel, the coordinate of its center
is projected back to source coordinates and the source pixel containing that
coordinate is identified. If this source pixel is invalid, the target pixel
is considered as nodata.
.IP \(bu 2
for bilinear, cubic, cubicspline and lanczos, for each target pixel, the
coordinate of its center is projected back to source coordinates and a
corresponding source pixel is identified. If this source pixel is invalid, the
target pixel is considered as nodata.
Given that those resampling kernels have a non\-null kernel radius, this source
pixel is just one among other several source pixels, and it might be possible
that there are invalid values in those other contributing source pixels.
The weights used to take into account those invalid values will be set to zero
to ignore them.
.IP \(bu 2
for the other resampling methods, source pixels contributing to the target pixel
are ignored if invalid. Only the valid ones are taken into account. If there are
none, the target pixel is considered as nodata.
.UNINDENT
.sp
If using \fI\%\-srcnodata\fP for multiple images with different invalid
values, you need to either (a) pre\-process them to have the same to\-be\-ignored
value, or (b) set the nodata flag for each file. Use (b) if you need to preserve
the original values for some reason, for example:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
# for this image we want to ignore black (0)
gdalwarp \-srcnodata 0 \-dstnodata 0 orig\-ignore\-black.tif black\-nodata.tif

# and now we want to ignore white (0)
gdalwarp \-srcnodata 255 \-dstnodata 255 orig\-ignore\-white.tif white\-nodata.tif

# and finally ignore a particular blue\-grey (RGB 125 125 150)
gdalwarp \-srcnodata \(dq125 125 150\(dq \-dstnodata \(dq125 125 150\(dq orig\-ignore\-grey.tif grey\-nodata.tif

# now we can mosaic them all and not worry about nodata parameters
gdalwarp black\-nodata.tif grey\-nodata.tif white\-nodata.tif final\-mosaic.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.SH APPROXIMATE TRANSFORMATION
.sp
By default \fBgdalwarp\fP uses a linear approximator for the
transformations with a permitted error of 0.125 pixels. The approximator
basically transforms three points on a scanline: the start, end and middle.
Then it compares the linear approximation of the center based on the end points
to the real thing and checks the error. If the error is less than the error
threshold then the remaining points are approximated (in two chunks utilizing
the center point). If the error exceeds the threshold, the scanline is split
into two sections, and the approximator is recursively applied to each section
until the error is less than the threshold or all points have been exactly
computed.
.sp
The error threshold (in pixels) can be controlled with the gdalwarp
\fI\%\-et\fP switch. If you want to compare a true pixel\-by\-pixel reprojection
use \fI\%\-et 0\fP which disables this approximator entirely.
.SH MEMORY USAGE
.sp
Adding RAM will almost certainly increase the speed of \fBgdalwarp\fP\&.
That\(aqs not at all the same as saying that it is worth it, or that the speed
increase will be significant. Disks are the slowest part of the process.  By
default \fBgdalwarp\fP won\(aqt take much advantage of RAM. Using the flag
\fI\%\-wm 500\fP will operate on 500MB chunks at a time which is better than
the default. The warp memory specified by \fI\%\-wm\fP is shared among all
threads, so it is especially beneficial to increase this value when running
\fBgdalwarp\fP with \fI\%\-wo NUM_THREADS\fP (or its equivalent
\fI\%GDAL_NUM_THREADS\fP) greater than 1.
.sp
Increasing the I/O block cache size may also help. This can be done by
setting the \fI\%GDAL_CACHEMAX\fP configuration like:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-\-config GDAL_CACHEMAX 500 \-wm 500 ...
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
This uses 500MB of RAM for read/write caching, and 500MB of RAM for working
buffers during the warp. Beyond that it is doubtful more memory will make a
substantial difference.
.sp
Check CPU usage while \fBgdalwarp\fP is running. If it is substantially
less than 100% then you know things are IO bound. Otherwise they are CPU bound.
The \fB\-\-debug\fP option may also provide useful information. For instance, after
running the following:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-\-debug on abc.tif def.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
a message like the following will be output:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
GDAL: 224 block reads on 32 block band 1 of utm.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
In this case it is saying that band 1 of \fButm.tif\fP has 32 blocks, but
that 224 block reads were done, implying that lots of data was having to be
re\-read, presumably because of a limited IO cache. You will also see messages
like:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
GDAL: GDALWarpKernel()::GWKNearestNoMasksByte()
Src=0,0,512x512 Dst=0,0,512x512
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
The Src/Dst windows show you the \(dqchunk size\(dq being used. In this case my whole
image which is very small. If you find things are being broken into a lot of
chunks increasing \fI\%\-wm\fP may help somewhat.
.sp
But far more important than memory are ensuring you are going through an
optimized path in the warper. If you ever see it reporting
\fBGDALWarpKernel()::GWKGeneralCase()\fP you know things will be relatively slow.
Basically, the fastest situations are nearest neighbour resampling on 8bit data
without nodata or alpha masking in effect.
.SH COMPRESSED OUTPUT
.sp
In some cases, the output of \fBgdalwarp\fP may be much larger than the
original, even if the same compression algorithm is used. By default,
\fBgdalwarp\fP operates on chunks that are not necessarily aligned with
the boundaries of the blocks/tiles/strips of the output format, so this might
cause repeated compression/decompression of partial blocks, leading to lost
space in the output format.
.sp
The situation can be improved by using the \fBOPTIMIZE_SIZE\fP warping option
(\fI\%\-wo OPTIMIZE_SIZE=YES\fP), but note that depending on the source and
target projections, it might also significantly slow down the warping process.
.sp
Another possibility is to use \fBgdalwarp\fP without compression and then
follow up with \fBgdal_translate\fP with compression:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp infile tempfile.tif ...options...
gdal_translate tempfile.tif outfile.tif \-co compress=lzw ...etc.
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
Alternatively, you can use a VRT file as the output format of \fBgdalwarp\fP\&. The
VRT file is just an XML file that will be created immediately. The
\fBgdal_translate\fP operations will be of course a bit slower as it will do the
real warping operation.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-of VRT infile tempfile.vrt ...options...
gdal_translate tempfile.vrt outfile.tif \-co compress=lzw ...etc.
.ft P
.fi
.UNINDENT
.UNINDENT
.SH EXAMPLES
.INDENT 0.0
.IP \(bu 2
Basic transformation:
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-t_srs EPSG:4326 input.tif output.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.INDENT 0.0
.IP \(bu 2
For instance, an eight bit spot scene stored in GeoTIFF with
control points mapping the corners to lat/long could be warped to a UTM
projection with a command like this:
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-t_srs \(aq+proj=utm +zone=11 +datum=WGS84\(aq \-overwrite raw_spot.tif utm11.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.INDENT 0.0
.IP \(bu 2
For instance, the second channel of an ASTER image stored in HDF with
control points mapping the corners to lat/long could be warped to a UTM
projection with a command like this:
.INDENT 2.0
.INDENT 3.5
New in version 2.2.

.UNINDENT
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-overwrite HDF4_SDS:ASTER_L1B:\(dqpg\-PR1B0000\-2002031402_100_001\(dq:2 pg\-PR1B0000\-2002031402_100_001_2.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.INDENT 0.0
.IP \(bu 2
To apply a cutline on a un\-georeferenced image and clip from pixel (220,60) to pixel (1160,690):
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-overwrite \-to SRC_METHOD=NO_GEOTRANSFORM \-to DST_METHOD=NO_GEOTRANSFORM \-te 220 60 1160 690 \-cutline cutline.csv in.png out.tif
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
where cutline.csv content is like:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
id,WKT
1,\(dqPOLYGON((....))\(dq
.ft P
.fi
.UNINDENT
.UNINDENT
.INDENT 0.0
.IP \(bu 2
To transform a DEM from geoid elevations (using EGM96) to WGS84 ellipsoidal heights:
.INDENT 2.0
.INDENT 3.5
New in version 2.2.

.UNINDENT
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
gdalwarp \-overwrite in_dem.tif out_dem.tif \-s_srs EPSG:4326+5773 \-t_srs EPSG:4979
.ft P
.fi
.UNINDENT
.UNINDENT
.SH C API
.sp
This utility is also callable from C with \fI\%GDALWarp()\fP\&.
.SH SEE ALSO
.sp
\fI\%Wiki page discussing options and behaviours of gdalwarp\fP
.SH AUTHOR
Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@intevation.de>
.SH COPYRIGHT
1998-2024
.\" Generated by docutils manpage writer.
.
